#lang racket
(define (fib n)
  (fib-iter 1 0 0 1 n))

(define (fib-iter a b p q count)
  (cond
    ((= count 0) b)
    ((even? count) (fib-iter
                    a
                    b
                    (+ (* p p) (* q q))
                    (+ (* 2 p q) (* q q))
                    (/ count 2)))
    (else (fib-iter
           (+ (* b q) (* a q) (* a p))
           (+ (* b p) (* a q))
           p
           q
           (- count 1)))))

;; (+ (fib 9) (fib 10))
;; (fib 11)
;; (/ (fib 100) (fib 99))

(define (calculate-without-printing n)
  (fib n)
  'done)
(time (calculate-without-printing 100000000))
